package cn.edu.scau.cmi.liangzijian.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {

	Object target = null;
	
	public MyInvocationHandler(Object target) {
		this.target = target;
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		//((DVisit)proxy).browse();	proxy就是Proxy实例，不可以在invoke中调用实现的方法，不然会死循环直到栈溢出
		//System.out.println("call method " + method.getName());
		Object result = method.invoke(target, args);
		return result;
	}

}
